package edu.szcu.cstms_admin.service.impl;

import edu.szcu.cstms_admin.dao.UserInfoDao;
import edu.szcu.cstms_admin.entity.UserInfo;
import edu.szcu.cstms_admin.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户信息服务实现类
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    @Transactional
    public int insert(UserInfo userInfo) {
        return userInfoDao.insert(userInfo);
    }

    @Override
    public UserInfo selectById(Long id) {
        return userInfoDao.selectById(id);
    }

    @Override
    public UserInfo selectByStudentWorkerId(String studentWorkerId) {
        return userInfoDao.selectByStudentWorkerId(studentWorkerId);
    }

    @Override
    public UserInfo selectByName(String name) {
        return userInfoDao.selectByName(name);
    }

    @Override
    public List<UserInfo> selectAll() {
        return userInfoDao.selectAll();
    }

    @Override
    public List<UserInfo> selectByCollege(String college) {
        return userInfoDao.selectByCollege(college);
    }

    @Override
    @Transactional
    public int update(UserInfo userInfo) {
        return userInfoDao.update(userInfo);
    }

    @Override
    @Transactional
    public int deleteById(Long id) {
        return userInfoDao.deleteById(id);
    }

    @Override
    @Transactional
    public int deleteByStudentWorkerId(String studentWorkerId) {
        return userInfoDao.deleteByStudentWorkerId(studentWorkerId);
    }

    @Override
    public int count() {
        return userInfoDao.count();
    }

    @Override
    public List<UserInfo> selectByCondition(UserInfo userInfo) {
        return userInfoDao.selectByCondition(userInfo);
    }

    @Override
    public UserInfo login(String studentWorkerId, String password) {
        // 直接使用DAO层的方法进行登录验证
        return userInfoDao.selectByStudentWorkerIdAndPassword(studentWorkerId, password);
    }
}
